package com.phkj.qdh

import android.annotation.SuppressLint
import android.app.Application
import android.content.Context
import android.view.Gravity
import com.hjq.toast.ToastUtils
import com.phkj.qdh.net.OkHttpManager
import com.phkj.qdh.utils.SPSUtils
import com.phkj.qdh.utils.SPS_TOKEN
import me.jessyan.autosize.AutoSize
import me.jessyan.autosize.AutoSizeConfig
import rxhttp.RxHttpPlugins

class App:Application() {
    companion object{
        @SuppressLint("StaticFieldLeak")
        @JvmStatic
        @get:JvmName("CONTEXT")
        lateinit var CONTEXT:Context
            private set

    }

    override fun onCreate() {
        super.onCreate()
        CONTEXT = this
        ToastUtils.init(this)
        ToastUtils.setGravity(Gravity.BOTTOM,0,200)


//        AutoSize.initCompatMultiProcess(this)
//        AutoSize.checkAndInit(this)
//        AutoSizeConfig.getInstance().setLog(true).setBaseOnWidth(true).setDesignWidthInDp(375)
////            .setDesignHeightInDp(812)
//            .setPrivateFontScale(0f).setExcludeFontScale(false)
        RxHttpPlugins.init(OkHttpManager.mClient).setDebug(BuildConfig.DEBUG).setOnParamAssembly {
            //添加公共参数
//            if (SPSUtils.getString(SPS_DEVICE_ID).isBlank()) {
//                SPSUtils.put(SPS_DEVICE_ID, DeviceIdUtil.getDeviceId(this))
//            }
//            it.add("platform", "android")
//            it.add("optionSign", SPSUtils.getString(SPS_DEVICE_ID))
//            it.add("timestamp", "${System.currentTimeMillis()}")
//            it.add("apiToken", SPSUtils.getString("apiToken", ""))

//            if (SPSUtils.getString(SPS_TOKEN,"")!=""){
//                it.add("ACCESS_TOKEN",SPSUtils.getString(SPS_TOKEN,""))
//            }
        }
    }
}